package com.wt.mapper.impl;

import com.wt.entity.Order;
import com.wt.mapper.IRowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;

public class OrderRowMapper implements IRowMapper<Order> {

    @Override
    public Order rowMapper(ResultSet rs) throws SQLException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Order order = new Order();
        order.setOrderName(rs.getString("order_name"));
        order.setOrderStater(rs.getInt("order_stater"));
        order.setOrderPrice(rs.getDouble("order_price"));
        order.setScenicImage(rs.getString("scenic_image"));
        order.setUserId(rs.getString("user_id"));
        order.setOrderId(rs.getInt("order_id"));
        order.setOrderTime(sdf.format(rs.getTimestamp("order_time")));
        order.setTravelTime(sdf.format(rs.getTimestamp("travel_time")));
        return order;
    }
}
